import { myEnv } from '@/myEnv';
import { mergeRequest } from '@/utils';
type parmas = {
    goodsId: string;
    //TODO:此处最后要改成boolean不能使用 1|0 ,这是一个很蠢的事.
    value: '1' | '0';
};

type Rsponse = {
    code: string;
    message: string;
};

/** 修改收藏状态 */
export const apiPostSetCollection = async (parmas: parmas) => {
    const response: Rsponse = await sendRequest(parmas);
    return response;
};

const sendRequest = async (parmas: parmas) => {
    let response1: Rsponse;
    if (myEnv.IS_ON_LINE) {
        response1 = await mergeRequest({
            url: `user/set-favorite-goods`,
            method: 'POST',
            data: { ...parmas, value: +parmas.value },
        });
    } else {
        response1 = {
            code: '200',
            message: 'ok',
        };
    }
    return response1;
};
